home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / gui / app / eventStack.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  4KB  |  128 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. import sys
  5. import os
  6. import wx
  7.  
  8. class AppEventManager:
  9.     ui_events = [
  10.         wx.ID_NEW,
  11.         wx.ID_OPEN,
  12.         wx.ID_CLOSE_ALL,
  13.         wx.ID_CLOSE,
  14.         wx.ID_REVERT,
  15.         wx.ID_SAVE,
  16.         wx.ID_SAVEAS,
  17.         wx.ID_UNDO,
  18.         wx.ID_REDO,
  19.         wx.ID_PRINT,
  20.         wx.ID_PRINT_SETUP,
  21.         wx.ID_PREVIEW,
  22.         wx.ID_EXIT]
  23.     
  24.     def __init__(self):
  25.         pass
  26.  
  27.     
  28.     def RegisterEvents(self):
  29.         app = wx.GetApp()
  30.         for eventID in self.ui_events:
  31.             app.AddHandlerForID(eventID, self.ProcessEvent)
  32.             app.AddUIHandlerForID(eventID, self.ProcessUpdateUIEvent)
  33.         
  34.  
  35.  
  36.  
  37. class AppEventHandlerMixin:
  38.     
  39.     def __init__(self):
  40.         self.handlers = { }
  41.         self.uihandlers = { }
  42.         self.pushed_handlers = { }
  43.         self.pushed_uihandlers = { }
  44.  
  45.     
  46.     def AddHandlerForIDs(self, eventID_list, handlerFunc):
  47.         for eventID in eventID_list:
  48.             self.AddHandlerForID(eventID, handlerFunc)
  49.         
  50.  
  51.     
  52.     def AddHandlerForID(self, eventID, handlerFunc):
  53.         self.Bind(wx.EVT_MENU, self.HandleEvent, id = eventID)
  54.         if eventID in self.handlers:
  55.             self.pushed_handlers[eventID] = self.handlers[eventID]
  56.         
  57.         self.handlers[eventID] = handlerFunc
  58.  
  59.     
  60.     def AddUIHandlerForID(self, eventID, handlerFunc):
  61.         self.Bind(wx.EVT_UPDATE_UI, self.HandleUpdateUIEvent, id = eventID)
  62.         if eventID in self.uihandlers:
  63.             self.pushed_uihandlers[eventID] = self.uihandlers[eventID]
  64.         
  65.         self.uihandlers[eventID] = handlerFunc
  66.  
  67.     
  68.     def RemoveHandlerForIDs(self, eventID_list):
  69.         for eventID in eventID_list:
  70.             self.RemoveHandlerForID(eventID)
  71.         
  72.  
  73.     
  74.     def RemoveHandlerForID(self, eventID):
  75.         self.Unbind(wx.EVT_MENU, id = eventID)
  76.         self.handlers[eventID] = None
  77.         if eventID in self.pushed_handlers:
  78.             self.handlers[eventID] = self.pushed_handlers[eventID]
  79.         
  80.  
  81.     
  82.     def RemoveUIHandlerForID(self, eventID):
  83.         self.Unbind(wx.EVT_UPDATE_UI, id = eventID)
  84.         self.uihandlers[eventID] = None
  85.         if eventID in self.pushed_uihandlers:
  86.             self.uihandlers[eventID] = self.pushed_uihandlers[eventID]
  87.         
  88.  
  89.     
  90.     def HandleEvent(self, event):
  91.         e_id = event.GetId()
  92.         if e_id in self.handlers:
  93.             handler = self.handlers[e_id]
  94.             
  95.             try:
  96.                 if handler:
  97.                     return handler(event)
  98.             except wx.PyDeadObjectError:
  99.                 self.RemoveHandlerForID(e_id)
  100.             except:
  101.                 None<EXCEPTION MATCH>wx.PyDeadObjectError
  102.             
  103.  
  104.         None<EXCEPTION MATCH>wx.PyDeadObjectError
  105.         event.Skip()
  106.         return False
  107.  
  108.     
  109.     def HandleUpdateUIEvent(self, event):
  110.         e_id = event.GetId()
  111.         if e_id in self.uihandlers:
  112.             handler = self.uihandlers[e_id]
  113.             
  114.             try:
  115.                 if handler:
  116.                     return handler(event)
  117.             except wx.PyDeadObjectError:
  118.                 self.RemoveUIHandlerForID(e_id)
  119.             except:
  120.                 None<EXCEPTION MATCH>wx.PyDeadObjectError
  121.             
  122.  
  123.         None<EXCEPTION MATCH>wx.PyDeadObjectError
  124.         event.Skip()
  125.         return False
  126.  
  127.  
  128.